package com.ymatou.iapi.dguser.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.CreateUserBackBean;
import com.ymatou.iapi.dguser.parameter.GetUserInfoByMobileBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.GetUserInfoByMobileCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.utils.TestDataManager;
/**
*根据手机号码查询用户信息列表Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetUserInfoByMobile{
	private static GetUserInfoByMobileBean getuserinfobymobileBean;
	private static GetUserInfoByMobileCall getuserinfobymobileCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("根据手机号码查询用户信息列表Test");
	}

	@Before
	public void caseUp() {
		getuserinfobymobileBean=new GetUserInfoByMobileBean();
		getuserinfobymobileCall=new GetUserInfoByMobileCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getuserinfobymobileCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserInfoByMobile_001() {
		Logger.start(true,"普通用户，通过手机号获取信息，成功");
		try {
			UserCreateBean u = DGUserCallService.initSellerUsercreateBean();
			
			int user = DGUserCallService.UserCreateCall(u);
			getuserinfobymobileBean.setMobile(u.getMobile());
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("true", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserInfoByMobile_002() {
		Logger.start(true,"手机号为空，获取失败");
		try {
			getuserinfobymobileBean.setMobile("");
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("false", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserInfoByMobile_003() {
		Logger.start(true,"手机号错误，获取失败");
		try {
			UserCreateBean u = DGUserCallService.initSellerUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			getuserinfobymobileBean.setMobile(u.getMobile()+"1");
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("true", getuserinfobymobileCall.getString("success"), "验证success");
			Logger.verifyEquals(0,getuserinfobymobileCall.getJsonObject().get("userDtos").getAsJsonArray().size(), "验证没有返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GetUserInfoByMobile_004() {//没找到修改手机号的地方
		Logger.start(true,"用户修改手机号之后，使用老手机号获取，失败");
		try {
			UserCreateBean u = DGUserCallService.initSellerUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			getuserinfobymobileBean.setMobile(u.getMobile());
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("false", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_GetUserInfoByMobile_005() {//没找到修改手机号的地方
		Logger.start(true,"用户修改手机号之后，使用新手机号获取，成功");
		try {
			UserCreateBean u = DGUserCallService.initSellerUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			getuserinfobymobileBean.setMobile(u.getMobile());
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("true", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserInfoByMobile_006() {
		Logger.start(true,"用户修改区号之后，使用手机号获取，成功");
		try {
			UserCreateBean u = DGUserCallService.initSellerUsercreateBean();
			int user = DGUserCallService.UserCreateCall(u);
			getuserinfobymobileBean.setMobile(u.getMobile());
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("true", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserInfoByMobile_007() {
		Logger.start(true,"使用独立商家的手机号获取，成功");
		try {
			CreateUserBackBean b = DGUserCallService.initUsercreateNewBean();
			b.setMobile(TestDataManager.getPhoneNum());
			Integer user = DGUserCallService.UserCreateNewCall(b);
			getuserinfobymobileBean.setMobile(b.getMobile());
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("true", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetUserInfoByMobile_008() {
		Logger.start(true,"使用独立商家的手机号获取，成功");
		try {
			CreateUserBackBean b = DGUserCallService.initUsercreateNewBean();
			b.setMobile(TestDataManager.getPhoneNum());
			Integer user = DGUserCallService.UserCreateNewCall(b);
			getuserinfobymobileBean.setMobile(b.getMobile());
			getuserinfobymobileCall.setData(getuserinfobymobileBean);
			getuserinfobymobileCall.callService();			
			Logger.verifyEquals("true", getuserinfobymobileCall.getString("success"), "验证success");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
}